<%@page import="java.util.Iterator"%>
<%@page import="news.News"%>
<%@page import="java.util.ArrayList,java.text.SimpleDateFormat"%>
<%@page import="news.Newsdao,java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>和园一号新闻系统</title>
<link rel="shortcut icon"
	href="D:/apache-tomcat-9.0.31-windows-x64/apache-tomcat-9.0.31/webapps/ROOT/favicon.ico"
	type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="./css/index.css"/>
<link rel="stylesheet" type="text/css" href="./css/idangerous.swiper.css" />
<script src="/js/common.js" type="text/javascript"></script>
<script type="text/javascript" src="./js/idangerous.swiper.min.js"></script>
<script src="./js/jquery-migrate.min.js" type="text/javascript"></script>
<script src="./js/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-3.2.1.js"></script>
</head>
<body>

	<div class="topview">
		<span class="theme"><a href="/">和园一号</span><span class="left">信科学
			讲道理 说事实 正视听</span>
		<form action="./ServletNewsShow" target="_blank" class="fr">
			<input type="text" name="title" placeholder="请输入想要查找的新闻" class="find">
			<input type="submit" value="快速搜索" class="findbtn">
		</form>
	</div>
	<!-- banner -->
	<div id="banner_pc" class="focusBox swiper-container" style="margin: 0 auto">
		<ul class="pic swiper-wrapper" id="pic">
			<li style="width: 1420px; height: 300px;"><a href=""><img
					src="images/1.png" /></a></li>
			<li class="" style="width: 1420px; height: 300px;"><a href=""><img
					src="images/3.jpg" /></a></li>
			<li class="" style="width: 1420px; height: 300px;"><a href=""><img
					src="images/2.gif" /></a></li>
			<li class="" style="width: 1420px; height: 300px;"><a href=""><img
					src="images/building.jpg" /></a></li>
		</ul>
		<ol id="list" class=".pic_new .num">
			<li class="on">1</li>
			<li class="on">2</li>
			<li class="on" >3</li>
			<li class="on">4</li>
		</ol>
		<div class="bannerpc-pagination"></div>
	</div>
	<script type="text/javascript">
		window.onload = function() {
			var wrap = document.getElementById('banner_pc')
			var pic = document.getElementById('pic').getElementsByTagName("li")
			var list = document.getElementById('list').getElementsByTagName('li')
			var index = 0
			var timer = null;

			// 定义并调用自动播放函数
			timer = setInterval(autoPlay, 1000);
			// 鼠标划过整个容器时停止自动播放
			wrap.onmouseover = function() {
				clearInterval(timer);
			}
			// 鼠标离开整个容器时继续播放至下一张
			wrap.onmouseout = function() {
				timer = setInterval(autoPlay, 2000);
			}
			// 遍历所有数字导航实现划过切换至对应的图片
			for (var i = 0; i < list.length; i++) {
				list[i].onmouseover = function() {
					clearInterval(timer);
					index = this.innerText - 1;
					changePic(index);
				};
			}
			;
			function autoPlay() {
				if (++index >= pic.length)
					index = 0;
				changePic(index);
			}
		// 定义图片切换函数
			function changePic(curIndex) {
				for (var i = 0; i < pic.length; ++i) {
					pic[i].style.display = "none";
					list[i].className = "";
				}
				pic[curIndex].style.display = "block";
				list[curIndex].className = "on";
			}

		};
	</script>
		<%
		Newsdao newsdao = new Newsdao();
		ArrayList<News> list = newsdao.doNewsQueryByTitle();
		Iterator<News> iterator = list.iterator();
			while (iterator.hasNext()) {
				News news = iterator.next();
				SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//定义格式，不显示毫秒
				Timestamp now = news.getPubtime();
				String str = df.format(now);
				String[] b = str.split("-");
				String year = b[0];
				String month = b[1];
				String today = str.substring(8);
				int isValid = news.getIsValid();
				int isTop = news.getIsTop();
				if(isTop == 1){
					%>
	<div class="bk01 cen">
		<div class="tt_new">
			<img src="./images/tt_bt.png"> <a
				href="${pageContext.request.contextPath}/ServletNewsList?nid=<%=news.getNid() %>" target="_blank"
				title="<%=news.getTitle()%>"><h3 class="show"><%=news.getTitle() %></h3>
				<p class="show"><%=news.getContent() %></p> </a>
		</div>
				<%
             }
			
			if (isValid == 1) {
		%>
		<div class="pic_lb">
			<ul>
				<li><a href="${pageContext.request.contextPath}/ServletNewsList?nid=<%=news.getNid() %>" target="_blank" title="<%=news.getTitle()%>">
						<h3><%=news.getTitle()%></h3>
						<p class="show"><%=news.getContent()%></p>
				    </a>
					<h4><%=today%><span><%=year + "." + month%></span></h4>
				</li>
			</ul>
		</div>
        
	<%
				}
				
			}
	%>
	</div>
	<div>
	     
	</div>
</body>
</html>